
BEGIN
DROP TABLE trials
DROP TABLE person2queue
DROP TABLE trialState
END

CREATE TABLE trials
(
	trialID int IDENTITY(1,1) NOT NULL,
	name nvarchar(100),
	description nvarchar(1000),
	startClockTime datetime DEFAULT GETUTCDATE(),
	endClockTime datetime,
	duration float,
	PRIMARY KEY(trialID),
)

CREATE TABLE person2queue
(
	trialID int,
	personID int IDENTITY(1,1),
	queueID int,
	startTime float,
	endTime float,
	FOREIGN KEY(trialID) REFERENCES trials(trialID),
	PRIMARY KEY(trialID,personID,queueID)
)

CREATE TABLE trialState
(
	trialID int,
	iteration int,
	iterationTime datetime DEFAULT GETUTCDATE(),
	lastTime float,
	currTime float,
	queue1length int,
	queue2length int,
	nextEntry float,
	nextPaper1 float,
	nextPaper2 float,
	nextPaper3 float,
	nextPaper4 float,
	nextPhoto1 float,
	nextPhoto2 float,
	FOREIGN KEY(trialID) REFERENCES trials(trialID),
	PRIMARY KEY(trialID,iteration)
) 
	
	
